import time

from appium.webdriver.common.mobileby import MobileBy
from selenium.webdriver.common.by import By

from Hogwarts.Homeworks.hw0701.page_objects.base import Base


"""
PAGE：通讯录页面
"""


class PageContact(Base):

    # OBJECTS
    _ADD_MEMBER = (MobileBy.XPATH, "//*[@text='添加成员']")
    _ITEMS_MEMBER = (MobileBy.XPATH, "//*[@resource-id='com.tencent.wework:id/hiz']/android.widget.TextView")

    def click_add_member(self):
        """
        点击"添加成员"
        :return:
        """
        from Hogwarts.Homeworks.hw0701.page_objects.page_contact_add_choose import PageContactAddChoose

        self.find_and_click(*self._ADD_MEMBER)
        return PageContactAddChoose(self.driver)

    def get_member_names(self):
        """
        获取部门名字，方便后续断言使用
        :return:
        """

        member_name_list = []
        elements = self.finds(*self._ITEMS_MEMBER)
        for ele in elements:
            member_name_list.append(ele.text)
        return member_name_list
